var app = getApp();

Page({
    data: {
        tupl:0,
        rindtg:false,
    },
    onLoad: function (options) {
        app.func.api.refreshToken().then(token => {
            console.log("token:" + token);
        });
    },

    onShow: function () {
        this.banner();
        var accountinfo = wx.getAccountInfoSync();
        var version = accountinfo.miniProgram.envVersion;
        console.log("version:" + version);
        var type = 1;
        if(version == 'release') {
            type = 2;
        }
        app.func.getPromise(`/address/getConfig/?type=${type}`)
            .then(([code,res]) => {
                let showCom =JSON.parse(res.data.decoration)
               this.setData({
                   showCom: JSON.parse(res.data.decoration)
               })
               if(showCom[0].type =='yidianli'){
                this.setData({
                 tupl:0,
                 tylip:1
                })
            }else if(showCom[0].type =='dongyi'|| showCom[0].type =='chacheng' ||showCom[0].type =='nuodi'){
                this.setData({
                    tupl:0,
                    tylip:1
                   })
            }else {
                this.setData({
                    tupl:1
                })
            }
               console.log(JSON.parse(res.data.decoration))
            });
    },
    banner: function () {
        app.func.getPromise('/list/banner')
            .then(([code, res]) => {
                this.setData({banner: res.data});
            })
    },
    onPageScroll:function(e){
       if(this.data.tylip==1){
        if(e.scrollTop>40){
            this.setData({
                tupl:1
            })
        }else if(e.scrollTop<40){
            this.setData({
                tupl:0
            })
        }
       }
       
      },
 
 
     //右上角分享功能
   onShareAppMessage () {
        return {
           success (res) {
             console.log('分享成功！')
           }
        }
      }
    
});